package nonfixcycle

import (
	"blockchain/public/entity"
	"crypto/sha256"
	"encoding/json"
)

type commit2Message struct {
	block entity.Block
	priSeq int
}

func commit2(priSeq int,round int,commit2Msg *commit2Message){
		commit2Msg.block.Height=round
		var prehash []byte
		if round!=0{
			prehash,_=json.Marshal(blockchain[round-1])
		}
		commit2Msg.block.PreBlockHash=sha256.Sum256(prehash)
		commit2Msg.block.Timestamp=TradeSet[priSeq][round%5][0].Timestamp
		commit2Msg.block.Trades=TradeSet[priSeq][round%5]
		commit2Msg.priSeq=priSeq
		var data =make([][]byte,2)
		data[0],_=json.Marshal(commit2Msg.block)
}

func sendCommit2ToNode(priSeq int,commit2 *commit2Message){
	chanReply<-*commit2
	FlagReplied[priSeq]<-true
	close(FlagReplied[priSeq])
}
func sendCommit2ToNode1(priSeq int,commit2 *commit2Message){
	chanReply_1<-*commit2
	FlagReplied_1[priSeq]<-true
	close(FlagReplied_1[priSeq])
}

